Typesafe Code Reuse Across ASTs via Code Generation

نویسندگان

  • Mikoláš Janota
  • S. Oliveira
  • Viliam Holub
چکیده

Writing data structures for abstract syntax trees (ASTs) in a conventional OO programming language is tedious and error-prone. Hence, programmers often use AST generators to generate OO code from a higher-level description. This article argues that the existing AST generators do not provide good support for programs that manipulate several similar structural variations of an AST. Using a conventional code generator for such family of ASTs either leads to code duplication or a loss of static type-safety. This article introduces extended ASTs (XASTs), a small language for capturing ASTs, and a code-generation algorithm for XASTs. Since XASTs are a variation of regular tree types they are ordered by a similar structural subtyping relation which is preserved by the generative algorithm. In contrast to existing AST code generators, our solution facilitates both code reuse and preserves static type-safety. We demonstrate the feasibility of our approach by providing an implementation of a code generator from XASTs to Java.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Dwarf Frankenstein is still in your memory: tiny code reuse attacks

Code reuse attacks such as return oriented programming and jump oriented programming are the most popular exploitation methods among attackers. A large number of practical and non-practical defenses are proposed that differ in their overhead, the source code requirement, detection rate and implementation dependencies. However, a usual aspect among these methods is consideration of the common be...

متن کامل

Aggrandizing the beast's limbs: patulous code reuse attack on ARM architecture

Since smartphones are usually personal devices full of private information, they are a popular target for a vast variety of real-world attacks such as Code Reuse Attack (CRA). CRAs enable attackers to execute any arbitrary algorithm on a device without injecting an executable code. Since the standard platform for mobile devices is ARM architecture, we concentrate on available ARM-based CRAs. Cu...

متن کامل

Java-COM integration with JACOB using XML wrappers

ManyWindows-based legacy applications can be programmatically accessed using COM interfaces. However, calling COM components from Java is not straightforward. This report compares four open source Java-COM integration packages. A technique for typesafe Java-COM integration is presented. The technique is based on typesafe COM interface wrappers using jcom, java2com and JACOB libraries. Examples ...

متن کامل

Abstract Syntax Networks for Code Generation and Semantic Parsing

Tasks like code generation and semantic parsing require mapping unstructured (or partially structured) inputs to well-formed, executable outputs. We introduce abstract syntax networks, a modeling framework for these problems. The outputs are represented as abstract syntax trees (ASTs) and constructed by a decoder with a dynamically-determined modular structure paralleling the structure of the o...

متن کامل

– I Don't See How You in Ten Pages Can Do the Whole Thing Completely Wrong!

Syntax Trees Abstract syntax trees (ASTs) contain the essence of programs. They are a minimal and precise form of syntax trees (sometimes called parse trees). Syntax trees are constructed by parsing the source code text. The resulting tree contains all the lexical tokens of the original source code, possibly also including whitespaces, represented as a tree according to a subject language gramm...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2009